package com.jic.market.controller.rest;

import com.jic.common.base.vo.PageResult;
import com.jic.common.base.vo.RestResult;
import com.jic.market.api.rest.SeckillRestApi;
import com.jic.market.request.rest.SeckillArrRequest;
import com.jic.market.request.rest.SeckillInfoRequest;
import com.jic.market.request.rest.seckill.CheckSeckillRequest;
import com.jic.market.request.rest.seckill.QueryGoodsListRequest;
import com.jic.market.request.rest.seckill.QueryProcessingGoodsListPageRequest;
import com.jic.market.request.rest.seckill.SeckillTimeListRequest;
import com.jic.market.response.PageResponse;
import com.jic.market.response.rest.SeckillArrResponse;
import com.jic.market.response.rest.SeckillInfoResponse;
import com.jic.market.response.rest.seckill.QueryGoodsListResponse;
import com.jic.market.response.rest.seckill.SeckillTimeListResponse;
import com.jic.market.service.rest.seckill.SeckillRestService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @author wwb
 */
@RestController
@Api(tags ={"秒杀H5接口"})
@RequestMapping("/rest/seckill")
public class SeckillRestController implements SeckillRestApi {

    @Resource
    private SeckillRestService seckillRestService;

//    @PostMapping("/query-time-list")
//    @ApiOperation("查询当天进行中的秒杀时间段列表")
//    @Override
//    public RestResult<List<SeckillTimeListResponse>> seckillTimeList(@Valid @RequestBody SeckillTimeListRequest request) {
//        return seckillRestService.seckillTimeList(request);
//    }
//
//    @PostMapping("query-goods-list")
//    @ApiOperation("查询时间段下商品列表-分页")
//    @Override
//    public RestResult<PageResult<QueryGoodsListResponse>> queryGoodsList(@Valid @RequestBody QueryGoodsListRequest queryGoodsListRequest){
//        return seckillRestService.queryGoodsList(queryGoodsListRequest);
//    }



    @PostMapping("/query-processing-goods-list-page")
    @ApiOperation("查询进行中的商品-分页")
    public RestResult<PageResult<QueryGoodsListResponse>> queryProcessingGoodsListPage(@Valid @RequestBody QueryProcessingGoodsListPageRequest request){
        return seckillRestService.queryProcessingGoodsListPage(request);
    }

    @PostMapping("/query-about-start-goods-list-page")
    @ApiOperation("查询未开始的商品列表")
    public RestResult<PageResult<QueryGoodsListResponse>> queryAboutStartGoodsListPage(@Valid @RequestBody QueryProcessingGoodsListPageRequest request){
        return seckillRestService.queryAboutStartGoodsListPage(request);
    }

    @PostMapping("/query-has-not-start-goods-list-page")
    @ApiOperation("查询已结束的商品列表")
    public RestResult<PageResult<QueryGoodsListResponse>> queryHasNotStartGoodsListPage(@Valid @RequestBody QueryProcessingGoodsListPageRequest request){
        return seckillRestService.queryHasNotStartGoodsListPage(request);
    }

    @Override
    @ApiOperation("校验商品是否正在进行")
    public RestResult<Boolean> checkSeckillProduct(CheckSeckillRequest request) {
        return seckillRestService.checkSeckillProduct(request);
    }

    @PostMapping("/query-period-Time")
    @ApiOperation("查询时间段")
    public RestResult<List<SeckillTimeListResponse>> queryPeriodOfTime(){
        return seckillRestService.queryPeriodOfTime();
    }
}
